package com.hjy.controller;

import com.hjy.common.domain.response.GoodsRes;
import com.hjy.common.result.Goods;
import com.hjy.common.result.PageResult;
import com.hjy.common.result.Result;
import com.hjy.service.EsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/goodsEs")
public class EsController {
    @Autowired
    private EsService esService;

    /**
     * 添加
     */
    @PostMapping("/addGoods")
    public Result addGoods (@RequestBody List<GoodsRes> goodsList){
        esService.addGoods(goodsList);
        return Result.success();
    }
    /**
     * 删除
     */
    @PostMapping("/fiandDel")
    public Result fiandDel (){
        esService.fiandDel();
        return Result.success();
    }
    /**
     * 搜索
     */
    @PostMapping("/selGoods")
    public Result<PageResult<Goods>> selGoods (@RequestBody Goods goods){
        PageResult<Goods> result =  esService.selGoods(goods);
        return Result.success(result);
    }
}
